function checkCompany(e) {
	return verify('isempty',e,function(){
		if(arguments[0]){
			message('companyTip','','');
		}else{
			message('companyTip','所属公司不能为空','tip tip-error');
		}
	}); 
}

function checkAddress(e) {
	return verify('isempty',e,function(){
		if(arguments[0]){
			message('addressTip','','');
		}else{
			message('addressTip','工作地址不能为空','tip tip-error');
		}
	}); 
}

function checkTel(e) {
	var result = verify('isempty',e);
	if(result){
		result = verify('istel',e,function(){
				if(arguments[0]){
					message('telTip','','');
				}else{
					message('telTip','电话号码格式不正确','tip tip-error');
				}
			});
	}else{
		message('telTip','固定电话与手机号码至少填写一项','');
	}
	return result;
}

function checkPhone(e) {
	var result = verify('isempty',e);
	if(result){
		result = verify('isphone',e,function(){
				if(arguments[0]){
					message('phoneTip','','');
				}else{
					message('phoneTip','手机号码格式不正确','tip tip-error');
				}
			});
	}else{
		message('phoneTip','固定电话与手机号码至少填写一项','');
	}
	return result;
}

function checkLength() {
	var checkNumber = 0;
	var element = document.getElementsByName('plate[]');
	for (var i=0;i<element.length;i++) {
		if (element[i].checked == true) {
			checkNumber += 1;
		}
	}
	if (checkNumber > 3) {
		message('plateTip','商圈最多选择3个','tip tip-error');
		result = false;
	} else {
		message('plateTip','','');
		result = true;
	}
	return result;
}

function checkPhoneOrTel(){
	var phone = verify('isempty','phone');
	var tel = verify('isempty','tel');
	var ifphone = checkPhone('phone');
	var iftel = checkTel('tel');
	if(!phone && !tel){
		message('telTip','电话号码与手机号码必填其一','tip tip-error');
		return false;
	}else if (phone && tel){
		return ifphone && iftel;
	}else {
		return ifphone || iftel;
	}
	return true;
}

function checkForm() {
	var company, address, tel, phone, telorphone, len;
	company = checkCompany('company');
	address = checkAddress('address');
	tel = checkTel('tel');
	phone = checkPhone('phone');
	telorphone = checkPhoneOrTel();
	len = checkLength();
	if (company && address && len && (tel || phone ) && telorphone) {
		return true;
	}
	return false;
}